
import MoorSwitch from './packages/switch/index.js';
import defaultLocal from './local/zh-CN.js';

const components = [
  MoorSwitch
]



const install = function (Vue, opts = {}) {

  if (install.installed) return;

  components.forEach((key) => {
    Vue.component(key.name, key);
  });


  Vue.prototype.$IVIEW = {
    size: opts.size || '',
    transfer: 'transfer' in opts ? opts.transfer : '',
    theme: 'theme' in opts ? opts.theme : 'a',
    lang: 'lang' in opts ? opts.lang : 'zh-CN',
  };


  //多主题
  Vue.burgeonTheme = function (option) {
    document.querySelector('body').setAttribute('class', '')
    document.querySelector('body').setAttribute('class', option)
  }

  Vue.burgeonTheme(Vue.prototype.$IVIEW.theme)



  //多语言
  Vue.burgeonLocal = function (option) {
    Vue.prototype.burgeonLang = option
  }

  Vue.burgeonLocal(defaultLocal)

}

/* 支持使用标签的方式引入 */
if (typeof window !== 'undefined' && window.Vue) {
  install(window.Vue);
}

const API = {
  install,
  MoorSwitch,
}

export default API;